<?php
use Workerman\Worker;
use GatewayWorker\Gateway;
use Workerman\Connection\TcpConnection as Connection;

$gateway = new Gateway('Websocket://0.0.0.0:7272');

$gateway->name = 'ChatGateWay';

$gateway->count = 4;
// 内部通讯端口
$gateway->startPort = 2300;

$gateway->pingInterval = 100;

$gateway->pingData = json_encode([
    'type'=>'ping'
]);

$gateway->registerAddress = '0.0.0.0:1236';

//$gateway->onConnect = function (Connection $conn){
//    $conn->onWebSocketConnect = function ($connection,$http_header)
//    {
//        if($_SERVER['HTTP_ORIGIN'] == 'http://0.0.0.0:55151'){
//            $connection->send('{"type":"ping"}');
//        }else{
//            $connection->close();
//        }
//    };
//};

if (!defined('GLOBAL_START')){
    Worker::runAll();
}
